package com;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.connection.jdbconnection;

public class AddNotification extends HttpServlet {

	
	Connection conn;
	Statement st;
	
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session=request.getSession();
		String id=request.getParameter("nid");
		String message=request.getParameter("message");
		System.out.println(id);
		System.out.println(message);
	
		try {
			
			jdbconnection jdbconnection=new jdbconnection();
			st= jdbconnection.jdbConnection();
			String sql="Insert into notification values('"+id+"','"+message+"')";
			st.execute(sql);
			System.out.println("User Detail Submit Successfully.");

			session.setAttribute("error", new Object());
			response.sendRedirect("AddNotification.jsp");
		}catch (Exception e) {
			e.printStackTrace();
			
		}
	
	
	}

}
